<?php
 /******************************************************************************
 *   GunCMS is an avid supporter of open source software. This is the appropriate 
 *   option if you are creating an open source application with a license 
 *   compatible with the GNU GPL license v3.
 *   For details http://www.gnu.org/licenses/gpl.html
 *   DO NOT USE FOR COMMERCIAL WITHOUT PERMISSION
 *
 * GunCMS Version 1.0.3
 * Copyright(c) 2009-2010, T & L GdbR
 * info@guncms.de
 * 
 * http://www.guncms.de
 ********************************************************************************/
class FgcmsTemplateBean  {
    public function TemplateBean() {
      
    }
      
    public function get_all_template($db) {
      	$sql = sprintf("SELECT * FROM %1\$s ORDER BY id ASC", TBL_TEMPLATE);
      	return $db->get_results($sql);
    }
      
    public function select_template($db, $id) {
  	$sql = sprintf("UPDATE  %s SET active = '0' WHERE active = '1'", TBL_TEMPLATE);					
  	$sql1 = sprintf("UPDATE  %s SET active = '1' WHERE id = '$id'", TBL_TEMPLATE);
  	$res = $db->query($sql);
  	if($res == true) {
            $res1 = $db->query($sql1);
  	}
        return $res1;
    }

    public function get_active_template($db){
        $sql = sprintf("SELECT name,id FROM %1\$s WHERE active = '1'", TBL_TEMPLATE);
        return $db->get_row($sql);
    }
}
?>